//
//  SettingViewController.m
//  2048
//
//  Created by 高新川 on 15/6/7.
//  Copyright (c) 2015年 高新川. All rights reserved.
//

#import "SettingViewController.h"
#import "UIColor+Hex.h"
#import "Game.h"

@implementation SettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor grayColor];
    
    UIButton *start = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    start.frame = CGRectMake(100, 64, 120, 40);
    start.layer.cornerRadius = 10.0;
    [start setTitle:@"取消" forState:UIControlStateNormal];
    start.backgroundColor = [UIColor colorWithHexString:@"0000FF"];
    [start addTarget:self action:@selector(makeSure) forControlEvents:UIControlEventTouchDown];
    [self.view addSubview:start];
    
    UIButton *simple = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    simple.frame = CGRectMake(100, 168, 120, 40);
    simple.layer.cornerRadius = 10.0;
    [simple setTitle:@"低级" forState:UIControlStateNormal];
    simple.backgroundColor = [UIColor colorWithHexString:@"0000FF"];
    [simple addTarget:self action:@selector(simpleGame) forControlEvents:UIControlEventTouchDown];
    [self.view addSubview:simple];

    UIButton *mid = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    mid.frame = CGRectMake(100, 272, 120, 40);
    mid.layer.cornerRadius = 10.0;
    [mid setTitle:@"中级" forState:UIControlStateNormal];
    mid.backgroundColor = [UIColor colorWithHexString:@"0000FF"];
    [mid addTarget:self action:@selector(midGame) forControlEvents:UIControlEventTouchDown];
    [self.view addSubview:mid];
    
    UIButton *high = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    high.frame = CGRectMake(100, 376, 120, 40);
    high.layer.cornerRadius = 10.0;
    [high setTitle:@"高级" forState:UIControlStateNormal];
    high.backgroundColor = [UIColor colorWithHexString:@"0000FF"];
    [high addTarget:self action:@selector(highGame) forControlEvents:UIControlEventTouchDown];
    [self.view addSubview:high];
}

/*
 * 简单按钮事件
 **/
- (void)simpleGame {
    [Game getInstance].model.matrix = 4;
    [self dismissViewControllerAnimated:YES completion:nil];
    [[NSNotificationCenter defaultCenter] postNotificationName:SETTING_BACK object:@"simple"];
}

/*
 * 中级按钮事件
 **/
- (void)midGame {
    [Game getInstance].model.matrix = 5;
    [self dismissViewControllerAnimated:YES completion:nil];
    [[NSNotificationCenter defaultCenter] postNotificationName:SETTING_BACK object:@"mid"];
}

/*
 * 高级按钮事件
 **/
- (void)highGame {
    [Game getInstance].model.matrix = 6;  // 六阶矩阵
    [self dismissViewControllerAnimated:YES completion:nil];
    [[NSNotificationCenter defaultCenter] postNotificationName:SETTING_BACK object:@"high"];
}

/*
 * 取消按钮事件
 **/
- (void)makeSure {
    //[self dismissModalViewControllerAnimated:YES];
    [self dismissViewControllerAnimated:YES completion:nil];
    [[NSNotificationCenter defaultCenter] postNotificationName:SETTING_BACK object:@"cancel"];
}

@end
